<?php
/**
 * Location represents an location of a chip 
 */
class Location extends Model {
	
	public $id;
	public $lat;
	public $lng;

	/**
	 * constructs parent
	 */	
	function __construct() {
		parent::__contruct();
	}	
	
	/**
	 * String with locations for googlemaps 
	 * @return string with locations
	 */	
	function toString(){
		return $lat . "," . $lng;
	}
	
	/**  
	 * Save's a location object
	 * @return true if saved succesfully else return false 
	 */			
	function save() {		
		if(isset($this->id)) {
			if($this->db->update('location', $this)) {
				return true;
			};
		} else {
			if($this->db->insert('location', $this)) {
				return true;
			};
		}
		return false;
	}

}